load vec2.txt

intervals = 50;

min_x = 10000;
min_y = 10000;
max_x = -10000;
max_y = -10000;
for i = 1:length(vec2)
    x = vec2(i, 1);
    y = vec2(i, 2);
    if x==-1 && y==-1
        continue;
    end
    if x < min_x
        min_x = x;
    elseif x > max_x
        max_x = x;
    end
    if y < min_y
        min_y = y;
    elseif y > max_y
        max_y = y;
    end
end
interval_x = min_x:(max_x-min_x)/intervals:max_x;
interval_y = min_y:(max_y-min_y)/intervals:max_y;


load('meetup_small_1.mat');
group_event_matrix = zeros(intervals, intervals, group_num);
for i = 1:length(group_tag_new)
    group = group_tag_new(i, 1);
    tag = tag_table(group_tag_new(i, 2), 2);
    x = vec2(tag, 1);
    y = vec2(tag, 2);
    if x==-1 && y==-1
        continue;
    end
    x_index = 1;
    y_index = 1;
    for j = 1:intervals
        if x >= interval_x(j) && x <= interval_x(j+1)
            x_index = j;
            break;
        end
    end
    for j = 1:intervals
        if y >= interval_y(j) && y <= interval_y(j+1)
            y_index = j;
            break;
        end
    end
    group_tag_matrix(x_index, y_index, group) = group_tag_matrix(x_index, y_index, group)+1;
end
save('group_tag_1.mat', 'interval_x', 'interval_y', 'group_tag_matrix');

load('meetup_small_2.mat');
group_event_matrix = zeros(intervals, intervals, group_num);
for i = 1:length(group_tag_new)
    group = group_tag_new(i, 1);
    tag = tag_table(group_tag_new(i, 2), 2);
    x = vec2(tag, 1);
    y = vec2(tag, 2);
    if x==-1 && y==-1
        continue;
    end
    x_index = 1;
    y_index = 1;
    for j = 1:intervals
        if x >= interval_x(j) && x <= interval_x(j+1)
            x_index = j;
            break;
        end
    end
    for j = 1:intervals
        if y >= interval_y(j) && y <= interval_y(j+1)
            y_index = j;
            break;
        end
    end
    group_tag_matrix(x_index, y_index, group) = group_tag_matrix(x_index, y_index, group)+1;
end
save('group_tag_2.mat', 'interval_x', 'interval_y', 'group_tag_matrix');

load('meetup_small_3.mat');
group_event_matrix = zeros(intervals, intervals, group_num);
for i = 1:length(group_tag_new)
    group = group_tag_new(i, 1);
    tag = tag_table(group_tag_new(i, 2), 2);
    x = vec2(tag, 1);
    y = vec2(tag, 2);
    if x==-1 && y==-1
        continue;
    end
    x_index = 1;
    y_index = 1;
    for j = 1:intervals
        if x >= interval_x(j) && x <= interval_x(j+1)
            x_index = j;
            break;
        end
    end
    for j = 1:intervals
        if y >= interval_y(j) && y <= interval_y(j+1)
            y_index = j;
            break;
        end
    end
    group_tag_matrix(x_index, y_index, group) = group_tag_matrix(x_index, y_index, group)+1;
end
save('group_tag_3.mat', 'interval_x', 'interval_y', 'group_tag_matrix');